package com.javasist;

import com.javasist.com.domain.Dog;
import javassist.*;

import java.lang.reflect.Method;

/**
 * Created by pengfei on 16/7/22.
 */
public class Test {
    public static void main(String[] args) throws Throwable {
        Translator t = new MyTranslator();
        ClassPool pool = ClassPool.getDefault();
//        Loader cl = new Loader();
//        cl.addTranslator(pool, t);
//        cl.loadClass("com.javasist.Test");

        Dog o1= new Dog();
        o1.say();

        Loader loader = new Loader(pool);
        Class cls = loader.loadClass("com.javasist.com.domain.Dog");
        Object o = cls.newInstance();
        Method m = cls.getDeclaredMethod("say",null);
        m.invoke(o,null);
    }
}
